package com.why.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.why.entity.Search;
import com.why.entity.Student;
import com.why.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author hy-woo
 * @since 2022-05-30
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    IStudentService studentService;

    @RequestMapping("/list")
    public Page<Student> list(@RequestBody Search search){
        Page<Student> page = new Page<>(search.getPage(), search.getPageSize());
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
        if (search.getDatea()!=null){
            wrapper.gt("created",search.getDatea());
        }
        if (search.getDateb()!=null){
            wrapper.lt("created",search.getDateb());
        }
        Page<Student> page1 = studentService.page(page, wrapper);
        return page1;
    }

}
